package com.neusoft.mapper;

import com.neusoft.po.Vip;
import org.apache.ibatis.annotations.*;

@Mapper
public interface VipMapper {

    @Insert("insert into vip values(#{userId},#{userId},5)")
    public int saveVip(String userId);

    @Select("select count(*) from vip where userId=#{userId}")
    public int getVipById(String userId);

    @Select("select cuponQuantity from vip where userId=#{userId} and vipId=#{vipId}")
    public int getCouponById(@Param("userId") String userId, @Param("vipId") String vipId);

    @Update("update vip set cuponQuantity = cuponQuantity - 1 WHERE userId=#{userId} and vipId=#{vipId} and cuponQuantity >0")
    public int updateCuponQt(Vip vip);
}
